package com.lyl.syt.api;/**
 * @author Mr.Luo
 * @date 2022-05-26 15:24
 */

import com.lyl.syt.common.result.Result;
import com.lyl.syt.enums.PaymentTypeEnum;
import com.lyl.syt.service.WeixinPayService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Mr.Luo
 * @date 2022-05-26 15:24
 * @desc 微信支付
 */
@RestController
@RequestMapping("/api/order/weixin")
@RequiredArgsConstructor
public class WeixinApiController {
    private final WeixinPayService weixinPayService;

    @ApiOperation("生成支付二维码")
    @GetMapping("/createNative/{orderId}")
    public Result<Map<String,Object>> createNative(@PathVariable Long orderId){
        return Result.ok(weixinPayService.createNative(orderId));
    }

    @ApiOperation("查询订单状态")
    @GetMapping("/queryPayStatus/{orderId}")
    public Result queryPayStatus(@PathVariable Long orderId){
        return  weixinPayService.queryPayStatus(orderId, PaymentTypeEnum.WEIXIN.name());
    }

}
